package com.stx.test;

import java.util.Scanner;

/**
 * packageName com.stx.test
 *
 * @author YangYi
 * @className WhileDemo
 * @date 2025/9/8
 * @description TODO
 */
public class WhileDemo {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int choice;

        do {
            // 1. 先显示菜单（这个动作至少要做一次）
            System.out.println("\n--- Menu ---");
            System.out.println("1. Play Game");
            System.out.println("2. Load Game");
            System.out.println("3. Exit");
            System.out.print("Please enter your choice: ");

            // 2. 获取用户输入
            choice = scanner.nextInt();

            // 3. 处理用户选择
            switch (choice) {
                case 1:
                    System.out.println("Starting new game...");
                    break;
                case 2:
                    System.out.println("Loading saved game...");
                    break;
                case 3:
                    System.out.println("Exiting...");
                    break;
                default:
                    System.out.println("Invalid choice! Try again.");
            }
        } while (choice != 3); // 4. 如果用户选择的不是3（退出），就继续循环

        System.out.println("Thank you for playing!");
        scanner.close();
    }
}
